package cc.wsyw126.java.nowcoder.sword_offer;

/**
 * Created by dp on 17/3/25.
 */
public class ReplaceSpace {
    public String replaceSpace(StringBuffer str) {
        int length = str.length();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            if (str.charAt(i) == ' ') {
                sb.append("%20");
            } else {
                sb.append(str.charAt(i));
            }
        }
        return sb.toString();
    }
}
